/*
 * @Author: your name
 * @Date: 2021-09-16 20:09:20
 * @LastEditTime: 2022-01-13 20:56:31
 * @LastEditors: xuesong
 * @Description: In User Settings Edit
 * @FilePath: \BLE-SDK-SVN499-V03\projects\ble_peripheral\uart_ble\src\Remote\User_keyScan.h
 */
#ifndef __SLAVER_KSCAN__H__
#define __SLAVER_KSCAN__H__

#ifdef __cplusplus
extern "C" {
#endif


#include "types.h"
#include "gpio.h"

//========================================================
#define KeyOnOffPin	            P15
#define KeyChargPin	            P26
#define KeyFullPin	            P27
//========================================================
typedef	uint8_t KeyType_t;
typedef	union {
    struct
    {
        unsigned char Tare          : 1;    // 
        unsigned char onOff         : 1;    // 
        unsigned char Charg         : 1;    // 
        unsigned char ChargFull     : 1;    // 
    }flagBit;
    KeyType_t flagByte;
}KeyFlag_t;
#define  USEED_KEY_BIT      0x03
#define  TATE_BIT_PLASE     0
#define  ONOFF_BIT_PLASE    1
//========================================================
typedef struct KeyStatus{
    KeyFlag_t   Cont;
    KeyFlag_t   Trage;
    KeyFlag_t   ShortTrage;
    KeyFlag_t   ReleaseTrage;
    uint8_t     ClikckCnt[sizeof(KeyType_t)*8];
    KeyFlag_t   LongTrage;          //Frist long out put
    KeyFlag_t   LongFastTrage;      //contiue long out put
}KeyStatus_t;
//=========================================================
void KeyPinInt(void);
void KeyPowerDown(void);
KeyFlag_t __ATTR_SECTION_SRAM__ GetKeyBits(void);
// KeyStatus_t KeyScan(KeyFlag_t keyFlag);
void KeyScan(KeyStatus_t *keyFlag);
uint8_t CheckKeyClickTimes(KeyFlag_t CheckBit,const KeyStatus_t* const Key);
#ifdef __cplusplus
}
#endif


#endif

